package cn.itlaobing.dao;

import org.apache.commons.dbutils.QueryRunner;
import java.sql.SQLException;
import java.util.Map;

/**
 * Created by kevin on 2017/11/10.
 */
public class TrainDao extends BaseDao {
    public Map<String,Object> queryAll(String trainNum,String statrtStation,String endStation )throws SQLException{
        String sql="SELECT s1.trainNum,s1.station AS startStation,s2.station AS endStation,s2.sitePrice -s1.sitePrice AS price FROM station s1,station s2 WHERE s1.trainNum=s2.trainNum AND s1.trainNum=? AND s1.station=? AND s2.station=?";
        QueryRunner queryRunner=new QueryRunner(getDataSource());
        Map<String,Object> map =queryRunner.query(sql,new TrainResultHangler(),trainNum,statrtStation,endStation);
        return map;

    }

}
